From 4d8a0dde00bbf7e9c356fb1d197a90f5df211513 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 1 Aug 2024 06:52:03 -0600 Subject: [PATCH] enhance validate filter to report on track segments. (#1308) --- reference/validate_debug.log | 8 ++++---- validate.cc | 39 +++++++++++++++++++++--------------- validate.h | 4 +++- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/reference/validate_debug.log b/reference/validate_debug.log index 85e4f47e9..55630cc0c 100644 --- a/reference/validate_debug.log +++ b/reference/validate_debug.log @@ -3,11 +3,11 @@ Processing waypts point ct: 2, waypt_count: 2 Processing routes -route 0 ct: 2, waypt_count: 2 -route head ct: 1, route_count: 1 +route 0 ct: 2, waypt_count: 2, segments 1 +route head ct: 1, route_count: 1, total segment count: 1 total route point ct: 2, route_waypt_count: 2 Processing tracks -track 0 ct: 2, waypt_count: 2 -track head ct: 1, track_count: 1 +track 0 ct: 2, waypt_count: 2, segments 1 +track head ct: 1, track_count: 1, total segment count: 1 total track point ct: 2, track_waypt_count: 2 diff --git a/validate.cc b/validate.cc index f3d20d664..9c54f34ca 100644 --- a/validate.cc +++ b/validate.cc @@ -30,23 +30,28 @@ void ValidateFilter::validate_head(const route_head* /*unused*/) { head_ct += 1; - segment_ct_start = point_ct; + point_ct = 0; + segment_ct = 0; } void ValidateFilter::validate_head_trl(const route_head* header) { - int segment_waypt_ct = point_ct - segment_ct_start; + total_point_ct += point_ct; + total_segment_ct += segment_ct; if (debug) { - fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num, segment_waypt_ct, header->rte_waypt_ct()); + fprintf(stderr, "%s %d ct: %d, waypt_count: %d, segments %d\n", segment_type, header->rte_num, point_ct, header->rte_waypt_ct(), segment_ct); } - if (!debug && (segment_waypt_ct != header->rte_waypt_ct())) { - fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), segment_waypt_ct); + if (!debug && (point_ct != header->rte_waypt_ct())) { + fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), point_ct); } } -void ValidateFilter::validate_point(const Waypoint* /*unused*/) +void ValidateFilter::validate_point(const Waypoint* wpt) { point_ct += 1; + if (wpt->wpt_flags.new_trkseg) { + segment_ct += 1; + } } void ValidateFilter::process() @@ -71,39 +76,41 @@ void ValidateFilter::process() } head_ct = 0; - point_ct = 0; + total_point_ct = 0; + total_segment_ct = 0; segment_type = "route"; if (debug) { fprintf(stderr, "\nProcessing routes\n"); } route_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count()); - fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count()); + fprintf(stderr, "route head ct: %d, route_count: %d, total segment count: %d\n", head_ct, route_count(), total_segment_ct); + fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", total_point_ct, route_waypt_count()); } if (!debug && (head_ct != route_count())) { fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct); } - if (!debug && (point_ct != route_waypt_count())) { - fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct); + if (!debug && (total_point_ct != route_waypt_count())) { + fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), total_point_ct); } head_ct = 0; - point_ct = 0; + total_point_ct = 0; + total_segment_ct = 0; segment_type = "track"; if (debug) { fprintf(stderr, "\nProcessing tracks\n"); } track_disp_all(validate_head_f, validate_head_trl_f, validate_point_f); if (debug) { - fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count()); - fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count()); + fprintf(stderr, "track head ct: %d, track_count: %d, total segment count: %d\n", head_ct, track_count(), total_segment_ct); + fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", total_point_ct, track_waypt_count()); } if (!debug && (head_ct != track_count())) { fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct); } - if (!debug && (point_ct != track_waypt_count())) { - fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct); + if (!debug && (total_point_ct != track_waypt_count())) { + fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), total_point_ct); } if (checkempty) { diff --git a/validate.h b/validate.h index 7a91388dc..8c81c8587 100644 --- a/validate.h +++ b/validate.h @@ -45,8 +45,10 @@ private: char* opt_checkempty{}; bool checkempty{}; int point_ct{}; + int total_point_ct{}; + int segment_ct{}; + int total_segment_ct{}; int head_ct{}; - int segment_ct_start{}; const char* segment_type{}; QVector args = { { -- 2.30.2